//---------------------------------------------------------------------
// Author: jachymko
//
// Description: Base class implementing the PEHeader cmdlets.
//
// Creation Date: Dec 24, 2006
//---------------------------------------------------------------------
using System;
using System.IO;
using System.Management.Automation;
using Pscx.Commands.Internal;

namespace Pscx.Commands.Reflection
{
    public abstract class GetPortableExecutableCommandBase : PscxPathCommandBase
    {
        protected override void ProcessPath(string path)
        {
            PortableExecutableInfo info = null;
            
            try
            {
                info = new PortableExecutableInfo(path);
            }
            catch(Exception exc)
            {
                WriteError(new ErrorRecord(exc, "InvalidPEImage", ErrorCategory.InvalidData, path));
            }

            if(info != null)
            {
                ProcessImage(info);
            }
        }

        protected abstract void ProcessImage(PortableExecutableInfo info);
    }
}
